package com.ruyuan.seckilling.common;

/**
 * @author zhonghuashishan
 */
public interface CacheKey {

    // ------------------------------------------------秒杀活动服务
    String TRIGGER_PAGE_LOCK = "triggerPageLock";

    String PAGE_FAILEDCOMPENSATION_LOCK = "pageFailedCompensationLock";

    String TRIGGER_STOCK_LOCK = "triggerStockLock";

    String CLEAN_DATA_LOCK = "cleanDataLock";

    // ------------------------------------------------秒杀库存服务
    String SALABLE_STOCK = "salableStock";

    String LOCKED_STOCK = "lockedStock";

    String SALED_STOCK = "saledStock";

    String PREFIX_SECKILLING_STOCK = "seckillingStock:";

    static String buildStockKey(Long activityId, Long skuId) {
        return PREFIX_SECKILLING_STOCK + activityId + ":" + skuId;
    }

    // ------------------------------------------------秒杀抢购服务
    static String buildCheckUserKey(Long activity, Long userId) {
        return "checkUser:" + activity + ":" + userId;
    }

    static String buildCheckProductKey(Long activity, Long userId, Long skuId) {
        return "checkProduct:" + activity + ":" + userId + ":" + skuId;
    }

    // ------------------------------------------------秒杀下单服务
    static String buildConsumeCreateOrderKey(Long sequence, Long activityId, Long userId, Long skuId) {
        return "consumeCreateOrder:" + sequence + ":" + activityId + ":" + userId + ":" + skuId;
    }
}
